<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8" />
		<title>4.数学的方法</title>
	</head>
	<body>
		<script type="text/javascript" >
			let todos = [
				{id:'g76tyds76d',title:'吃饭',done:true},
				{id:'9i8u9sadou',title:'睡觉',done:false},
				{id:'oi7y87h898',title:'学习',done:true}
			]

			let id = 'g76tyds76d'
			
			//使用forEach实现，效率不是很高
			/* const x = todos.forEach((t)=>{
				console.log('@')
				if(t.id === id){
					t.done = !t.done
				}
			}) */

			//使用find实现，效率稍高一点
			const x = todos.find((t)=>{
				console.log('@')
				return t.id === id
			})
			x.done = !x.done
			console.log(x)
			




		</script>
	</body>
</html>